<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<script type="text/javascript" src="/static/js/head.js"></script>
<link rel="stylesheet" type="text/css" href="/static/css/contractList.css" />
</head> 
<body id="layout" class="easyui-layout">
	<div data-options="region:'center',border:false">
		<table id="infoDrid"></table>
	</div>
</body>
	<div id="toolbar">
	</div>
</html>

<script>
	$(function(){
		$.ajaxSetup({crossDomain: true, xhrFields: {withCredentials: true}});
		//数据表格加载
		gridLoad(1,15);	
	});
	//数据表格加载
	function gridLoad(pageNumber,pageSize) {
		$.ajax({
			url : getHost() + '/small_item/summary_by_time_range_detail',
			type : "POST",
			data : JSON.stringify({
				"pageNumber": pageNumber,
			    "pageSize": pageSize,
			    "endTimeBegin": sessionStorage.getItem('endTimeBegin'),
			    "endTimeEnd": sessionStorage.getItem('endTimeEnd'),
			    "firstPartyName" : sessionStorage.getItem('firstPartyName'),
			    "end" : sessionStorage.getItem('end'),
			    "cooperator" : sessionStorage.getItem('cooperator'),
			}),
			async : false,
			dataType : "json",
			contentType: 'application/json;charset=UTF-8',
			success : function(data) {
				if (data.code==200&&typeof(data.data) == "object") {
					var width = $('#infoDrid').parent().width();
					var height = $('#infoDrid').parent().height();
					$('#infoDrid').datagrid({
						toolbar : "#toolbar",
						data: data.data.rows,
						width : width,
						height : height,
						async : false,
						fit : true,
						border : false,
						singleSelect : true,
						fitColumns : true,
						striped : true,
						pagination : true,
						columns : [ [
							{field:'name',title:'小项名称' ,align:'center'},
							{field:'cooperator',title:'合作单位' ,align:'center'},
							{field:'startDate',title:'开始日期',align:'center'},
							{field:'endDate',title:'结束日期',align:'center'},
							{field:'status',title:'状态',align:'center',
								formatter: function(value,row,index){
									if(value=="2"){
										return "已结束";
									}else if(value=="1"){
										return "进行中";
									}else{
										return "";
									}
								}
							},
							{field:'checkAndAcceptDate',title:'验收日期',align:'center'},
							{field:'amount',title:'总金额',align:'center' },
							{field:'secondPartyConstructionCost',title:'乙方施工费',align:'center'},
							{field:'firstPartyMaterialCost',title:'甲方提供材料费',align:'center'},
							{field:'secondPartyMaterialCost',title:'乙方提供材料费',align:'center'},
							{field:'secondPartySafeProductionCost',title:'乙方安全生产费用',align:'center'},
							{field:'stipulatedFee',title:'规费',align:'center'},
							{field:'amountCashed',title:'小项回款额',align:'center'},
							{field:'secondPartyAuditFee',title:'乙方审计费',align:'center'},
							{field:'secondPartyDeductedAmount',title:'乙方扣款',align:'center'},
							{field:'taxAmount',title:'税金',align:'center'},
							{field:'managementFee',title:'管理费',align:'center'},
							{field:'invoiceAmount',title:'小项开票金额',align:'center'},
							{field:'balance',title:'应付尾款',align:'center'},
							{field:'accountPayable',title:'应付款',align:'center'},
							{field:'actualPayment',title:'实际付款',align:'center'},
							{field:'totalPaid',title:'尾款支付状态',align:'center',
								formatter: function(value,row,index){
									if(value){
										return "已支付";
									}else if(!value){
										return "未支付";
									}else{
										return "";
									}
								}
							},
						] ],
					});
					var p = $('#infoDrid').datagrid('getPager');
			        $(p).pagination({
			        	total : data.data.total,
			            pageSize: pageSize,
			            pageList: [15, 30, 50],
			            pageNumber : pageNumber,
			            beforePageText: '第',
			            afterPageText: '页    共 {pages} 页',
			            displayMsg: '当前显示 {from}-{to} 条记录,共 {total} 条记录',
			            showRefresh : false,
			            onSelectPage:function(pageNumber, pageSize){
			        		gridLoad(pageNumber,pageSize);
			        	}
			        });
				}else{
					$.messager.alert("提示",data.message);
				}
			}
		});
	}
</script>